﻿using Fee.FileAttachs;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Fee.Mapping.FileAttachs
{
    public class AuthProjectOrderFileAttachMapping : IEntityTypeConfiguration<AuthProjectOrderFileAttach>
    {
        public void Configure(EntityTypeBuilder<AuthProjectOrderFileAttach> modelBuilder)
        {
            modelBuilder
                .HasKey(t => new { t.FileId, t.OrderId });
            modelBuilder.HasOne(f => f.File).WithMany().HasForeignKey(f=>f.FileId);

            modelBuilder
                .HasOne(pt => pt.Order)
                .WithMany(t => t.Attaches)
                .HasForeignKey(pt => pt.OrderId);
            modelBuilder.ToTable("fee_authProjectFileAttach");
        }
    }
}